# encoding=utf8
import sys
import math
reload(sys)
sys.setdefaultencoding('utf8')
from ..obdMessageAnalysis import*

class OBD_01:
    result = []
    analysisDescription = ["数据采集时间:", "登入流水号:","多：", "SIM卡号:"]
    analysis01Length = [6,2,2,20]
    CollectTime = ""
    Login_num = ""
    more = ""
    ICCID = ""
    s=""
    def LogicAisle(self, protocolStr, header):
        print "header01=%s"%header[1].split(':')[1]
        print "protocolStr01=%s"%protocolStr
        print "header01=%s"%header
        count = 0
        for i in range(len(self.analysisDescription)):
            if i==0:
                str=protocolStr[count:count + (self.analysis01Length[i] * 2)]
                print "str=%s"%str
                self.proCollectTime(str)
                header.append(self.analysisDescription[i] + self.CollectTime + "\n")
            else:
                header.append(self.analysisDescription[i] + protocolStr[count:count + (self.analysis01Length[i] * 2)] + "\n");
            count = count + self.analysis01Length[i] * 2
        self.result = header
    def proCollectTime(self,timestr):
        i=0
        timelist =[]
        while i<len(timestr):
            print "proCollectTime=%d"%i
            print "proCollectTimelen=%d"%len(timestr)
            timestrnew=timestr[i:i+2]
            i=i+2
            timelist.append(str(int(timestrnew,16)))
            print "timelist=%s"%timelist
        timelist.insert(0, "20")
        timelist.insert(2, "年")
        timelist.insert(4, "月")
        timelist.insert(6, "日")
        timelist.insert(8, "时")
        timelist.insert(10, "分")
        timelist.insert(12, "秒")
        self.CollectTime = "".join(timelist)
